<?php

class Admin_SubjectController extends Zend_Controller_Action
{

    public function init()
    {
       $auth = Zend_Auth::getInstance ();
		if ($auth->hasIdentity ()) {
			if ($auth->getIdentity ()->role != 'administrator') {
				$this->_helper->redirector ( 'index', 'auth', 'default' );
			}
		} else {
			$this->_helper->redirector ( 'index', 'auth', 'default' );
		}
		$this->_helper->layout->setLayout ( 'admin' );
		/* Initialize action controller here */
    }

    public function indexAction()
    {
        // action body
    }
    
    public function saveAction()
    {
    	$request = $this->getRequest ();
		$responce = $this->getResponse ();
		if ($_POST) {
			$postData = $request->getPost ();
			$insert ['name'] = $postData ['p_subjectname'];
			$moClass = new Application_Model_Subjects();
			$moClass->save ( $insert );
			$result = array ('login' => true, 'result' => 'success', 'message' => '' );
			die ( json_encode ( $result ) );
		}
    }


}

